package express

import (
	"OnlineRetailers/controllers/errorDeal"
	"OnlineRetailers/models/Admin/resMes"
	error2 "OnlineRetailers/models/errorDeal"
	"OnlineRetailers/models/express"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
)

type GetExpress struct {
	beego.Controller
}

func (c *GetExpress) GetExpress() {
	defer func() {
		c.Ctx.Output.Header("Access-Control-Allow-Origin", "*")
		c.Ctx.Output.Status = 200
		c.ServeJSON()
	}()
	var addr = "/Express/GetExpress"
	res := resMes.GetExpress{}
	express1 := []*express.ExpressId{}
	log := &error2.Log{}

	var err error
	o := orm.NewOrm()

	sql := "select * from `express_id`"
	_, err = o.Raw(sql).QueryRows(&express1)

	if err != nil {
		c.Data["json"] = errorDeal.ErrMess(log, "400", err, addr, err.Error())
		return
	}

	res.Express = express1
	res.Code = "200"
	c.Data["json"] = res

}
